<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head> 
       <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title><spring:message code="company_account_createBankAccount"/></title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
   
     <script type="text/javascript">
     
     $(document).ready(function(){
    	 $("#consumptionCD").select2();
    	 $("#consumptionValue").select2();
    	 if ($("#sizeUnitCost").val()!=null&&$("#sizeUnitCost").val()!='') {
    	 	venderSelFun();
		}
    	 var form = $("#inputForm");  
	        form.validate();//验证指定的表单
	        	        
	        	$("#createButton").click(function(){
	        		if (form.valid()) {//如果表单验证成功，则进行提交。  
	        			addRows();
	                	
	                return false
	              }
	         });
 	});
     
     
    	
    	// 项目联动
    	function venderSelFun(){				
    			//项目子项联动
    			var consumptionCD = $("#consumptionCD").val().split('-')[1];
    			param={"consumptionCD":consumptionCD};
    	        $.post("${ctx}/fabric/consumption/findChild",param,function(result){            
    	            $("#consumptionChildHtml").html($(callBackHtml(result)).find("#consumptionChildHtml").html());
    	            $("#consumptionValue").select2();
    	        },'html');
    	}
    	
    	
                        function addRows() {
                        	//获取 iframe 数量 
                           	var frLength = window.parent.frames.length;
                           	//父画面下标 
                           	var parentIndex = frLength-2;
                           var consumptionValue = $("#consumptionValue").find("option:selected").val();
                           var itemCd = consumptionValue.split("-")[0];
                           var itemValue = consumptionValue.split("-")[1];
                           var sizeUnitCost = $("#sizeUnitCost").val();
                           var consumptionCn = $("#consumptionCD").find("option:selected").text();
                           var itemNameCn = $("#consumptionValue").find("option:selected").text();
                           window.parent.frames[parentIndex].addRow(itemCd,itemValue,itemNameCn,sizeUnitCost,consumptionCn);
                    	   closeWin();
                       }
                 
    </script> 
</head>
<body>
<!-- 创建页面head部 -->
<form id="inputForm">
<div class="layerHeader clearfix">	      
    <p class="headerTitle"><spring:message code="size_createSizeCost_child"/></p>    
    <div class="headerButton clearfix">
		  <button type="button" id="createButton"><spring:message code="common_save" /></button>
          <!-- 取消 -->
          <button type="button" onclick="closeWin()"><spring:message code="purchaseAdvance_edit_cancle"/></button>
    </div>
</div>


  <div id="showHtml" class="tabBoxSm">
   <div class="tabSm smOrderBox">
	   	   
       <div class="clearfix">
	     <div class="left w-350">
        		<!--设计项目 -->
	            <div class="items clearfix haveToBox">
            		<p class="tit"><spring:message code="size_design"/></p>          				                	              
          			<select style="width:200px" id="consumptionCD" name="consumptionCD"  onchange="venderSelFun();">
                            <option value=""><spring:message code="contract_edit_please"/></option>
	                       <c:forEach items="${consumptions}" var="consumptionCDInfo">
	                            <option  value="${consumptionCDInfo.consumptionCD}-${consumptionCDInfo.consumptionValue}" <c:if test="${consumption.consumptionCD eq consumptionCDInfo.consumptionValue }">selected="selected"</c:if> > 
	                                ${consumptionCDInfo.consumptionNameCn}
	                            </option>
	                       </c:forEach>
	               </select>  
        		</div>
        		<!-- 子项值  -->
        		<div class="items clearfix haveToBox" id="consumptionChildHtml">
            		<p class="tit"><spring:message code="size_value"/></p>            	       			 	                           		  
                	<select style="width:200px" id="consumptionValue" name="consumptionValue">
                            <option value=""><spring:message code="contract_edit_please"/></option>
	                       <c:forEach items="${consumptionChilds}"   var="ValueInfo">
	                            <option  value="${ValueInfo.consumptionCD}-${ValueInfo.consumptionValue}" <c:if test="${consumption.consumptionValue eq consumptionCDInfo.consumptionValue }">selected="selected"</c:if>> 
	                                ${ValueInfo.consumpChildNameCn}
	                            </option>
	                       </c:forEach>
	               </select>  
        		</div>
        		<!-- 单耗  -->
        		<div class="items clearfix haveToBox">        			
            		<p class="tit"><spring:message code="size_Cost"/></p>					
					<input id="sizeUnitCost" name="sizeUnitCost" value="${consumption.sizeUnitCost}" style="width: 200px" data-rule-required="true">
                </div>
                    
	     </div>	     
	   </div>  
    </div>
  </div>

</form>		
</body>
</html>